package April.fourteen;

public class Person {

    private String name;
    private int age;

    public static void main(String[] args) {

    }

//    重写toString
    public String toString(){

        return "["+name+"..."+age+"]";
    }

//    构造器
    public Person(){};
    public Person(String name,int age){
        this.age = age;
        this.name = name;
    }
//重写哈希
    public  int hashCcode(){
        return name.hashCode()+age;
    }
//重写aquals
    public boolean equals(Object j){
        if(this == j){
            return true;
        }else if(this == null){
            return false;
        }else if(j instanceof Person){
            Person p = (Person)j;
            return name.equals(p.name) && age==p.age;
        }return false;
    }
//

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
